<?php

/**
 * export actions.
 *
 * @package    webnews
 * @subpackage export
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class exportActions extends sfActions {
   
    public function  executeDownload(sfWebRequest $request) {
	// generate pdfs
	$pdf = new InsidePDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
	$pdf->printPage();
	$pdf2 = new CoverPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
	$pdf2->printPage();
	//TODO: create unique folder for current user
	$pdf->Output('/tmp/letak1.pdf', 'F');
	$pdf2->Output('/tmp/letak2.pdf', 'F');

	// zip pdfs
	$archive_filename = '/tmp/letak.zip';
	$zip = new ZipArchive();
	if ($zip->open($archive_filename, ZIPARCHIVE::CREATE) !== TRUE) {
	    die ("Could not open archive");
	}
	$zip->addFile('/tmp/letak1.pdf','letak1.pdf');
	$zip->addFile('/tmp/letak2.pdf','letak2.pdf');
	$zip->close();

	//output zip file
	header("Content-type: application/zip");
	header("Content-Disposition: attachment; filename=letak.zip");
	header("Pragma: no-cache");
	header("Expires: 0");
	readfile("$archive_filename");
	exit;
    }

}
